Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

morpheme-match-all

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

morpheme-match-all

A wrapper of morpheme-match API. Match all kuromoji's tokens.

  • 2.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
60K
increased by2.45%
Maintainers
1
Weekly downloads
 
Created
Source

morpheme-match-all

A wrapper of morpheme-match API. Match all kuromoji's tokens.

kuromojinのtoken同士を比較して、 形態素解析結果を元にしたtoken辞書による比較を行うライブラリです。

Install

Install with npm:

npm install morpheme-match-all

Overview

morpheme-match-all compare two kuromoji's tokens using morpheme-match.

You can see kuromoji's tokens at azu.github.io/morpheme-match/.

Dictionary

Define dictionary as tokens list.

"use strict";
module.exports = [
    {
        // https://azu.github.io/morpheme-match/?text=解析(することができます)。
        message: `"することができる"は有害 http://qiita.com/takahi-i/items/a93dc2ff42af6b93f6e0`,
        tokens: [
            {
                "surface_form": "する",
                "pos": "動詞",
                "pos_detail_1": "自立",
                "pos_detail_2": "*",
                "pos_detail_3": "*",
                "conjugated_type": "サ変・スル",
                "conjugated_form": "基本形",
                "basic_form": "する",
                "reading": "スル",
                "pronunciation": "スル"
            },
            {
                "surface_form": "こと",
                "pos": "名詞",
                "pos_detail_1": "非自立",
                "pos_detail_2": "一般",
                "pos_detail_3": "*",
                "conjugated_type": "*",
                "conjugated_form": "*",
                "basic_form": "こと",
                "reading": "コト",
                "pronunciation": "コト"
            },
            {
                "surface_form": "が",
                "pos": "助詞",
                "pos_detail_1": "格助詞",
                "pos_detail_2": "一般",
                "pos_detail_3": "*",
                "conjugated_type": "*",
                "conjugated_form": "*",
                "basic_form": "が",
                "reading": "ガ",
                "pronunciation": "ガ"
            },
            {
                "pos": "動詞",
                "pos_detail_1": "自立",
                "conjugated_type": "一段",
                "conjugated_form": "連用形",
                "basic_form": "できる",
            }
        ]
    }
];

morpheme-match-all the actual tokens generated by kuromojin(kuromoji.js).

const kuromojin = require("kuromojin");
const {createMatcher} = require("morpheme-match-all");
const dictionaries = require("./fixtures/dictionary");
const matchAll = createMatcher(dictionaries);
return kuromojin("解析することができます。").then((actualTokens) => {
    const results = matchAll(actualTokens);
    /**
[ { tokens: [ [Object], [Object], [Object], [Object] ],
index: 1,
expected: 
{ message: '"することができる"は有害 http://qiita.com/takahi-i/items/a93dc2ff42af6b93f6e0',
tokens: [Object] } } ]
     */
});

Usage

Table of Contents

ExpectedDictionary

Type: Object

Properties

MatchResult

Type: Object

Properties

createMatcher

Parameters

Returns morphemeMatchAll

morphemeMatchAll

match actualTokens with dictionaries

Parameters

Returns Array<MatchResult>

参考

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

Keywords

FAQs

Package last updated on 20 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc